﻿@{
    ViewBag.Title = "Fund";
}

<h2>Funds</h2>
<table style="width:100%;">
    <thead>
        <tr>
            <th>Fund Name</th>
            <th>Effective Date</th>
            <th>Valid Months</th>
            <th>End Date</th>
        </tr>
    </thead>
    <tbody id="funds">
    
    </tbody>
    <tfoot style="background-color:#58809a; color:White;">
        <tr>
            <td>Total Funds: <span id="total"></span></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tfoot>
</table>
<script type="text/javascript">
    $(function () {

        $.ajax({
            url: '/Fund/GetFunds', type: "POST",
            data: {},
            contentType: 'application/json; charset=utf-8',
            success: function (data) {
                var cnt = 0;
                $("#funds").find("tr").remove();
                $("#funds").find("td").remove();
                //$("#funds").append("<tr><td>"++"</td><td>"++"</td><td>"++"</td><td>"++"</td></tr>");
                $.each(data, function () {
                    $.each(this, function (k, v) {
                        $("#funds").append("<tr><td>" + v.FundName + "</td><td>" + v.EffectiveDate + "</td><td>" + v.ValidMonths + "</td><td>" + v.EndDate + "</td></tr>");
                        cnt = cnt + 1;
                    });
                });
                $("#total").text(cnt);
            }
        });
    });
</script>